<template>
	<view class="column-css">
		<view class="row-css" style="margin: 20rpx 60rpx;flex: 1;">
			<input style="background: #FFFFFF;width: 100%; padding: 10rpx;" v-model="bankName" @input="replaceInput" placeholder="搜索银行"></input>
		</view>
		<view class="column-css" style="position: fixed;width: 100%;height: 100%; margin-top: 100rpx;">
			<uni-indexed-list :options="options" :showSelect="false" @click="bindClick"></uni-indexed-list>
			<view v-if="isEmpty" style="text-align: center;color: #999;font-size: 28rpx;padding: 20px;">未搜索到该银行</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			bankName:'',
			options: [
				// {
				// 	letter: 'A',
				// 	data: [{bankName:'阿克苏机场',image:'https://y2t-nfp-dev-1258746579.cos.ap-guangzhou.myqcloud.com/17c71d650865473c94e8470d44daa920.png'}, {bankName:'阿克苏机场',image:'https://y2t-nfp-dev-1258746579.cos.ap-guangzhou.myqcloud.com/17c71d650865473c94e8470d44daa920.png'}, {bankName:'阿克苏机场',image:'https://y2t-nfp-dev-1258746579.cos.ap-guangzhou.myqcloud.com/17c71d650865473c94e8470d44daa920.png'}, {bankName:'阿克苏机场',image:'https://y2t-nfp-dev-1258746579.cos.ap-guangzhou.myqcloud.com/17c71d650865473c94e8470d44daa920.png'}, {bankName:'阿克苏机场',image:'https://y2t-nfp-dev-1258746579.cos.ap-guangzhou.myqcloud.com/17c71d650865473c94e8470d44daa920.png'}, {bankName:'阿克苏机场',image:'https://y2t-nfp-dev-1258746579.cos.ap-guangzhou.myqcloud.com/17c71d650865473c94e8470d44daa920.png'}]
				// },
				// {
				// 	letter: 'B',
				// 	data: [{bankName:'阿克苏机场',image:'https://y2t-nfp-dev-1258746579.cos.ap-guangzhou.myqcloud.com/17c71d650865473c94e8470d44daa920.png'}, {bankName:'阿克苏机场',image:'https://y2t-nfp-dev-1258746579.cos.ap-guangzhou.myqcloud.com/17c71d650865473c94e8470d44daa920.png'}, {bankName:'阿克苏机场',image:'https://y2t-nfp-dev-1258746579.cos.ap-guangzhou.myqcloud.com/17c71d650865473c94e8470d44daa920.png'}, {bankName:'阿克苏机场',image:'https://y2t-nfp-dev-1258746579.cos.ap-guangzhou.myqcloud.com/17c71d650865473c94e8470d44daa920.png'}, {bankName:'阿克苏机场',image:'https://y2t-nfp-dev-1258746579.cos.ap-guangzhou.myqcloud.com/17c71d650865473c94e8470d44daa920.png'}, {bankName:'阿克苏机场',image:'https://y2t-nfp-dev-1258746579.cos.ap-guangzhou.myqcloud.com/17c71d650865473c94e8470d44daa920.png'}]
				// },
				// {
				// 	letter: 'c',
				// 	data: [{bankName:'阿克苏机场',image:'https://y2t-nfp-dev-1258746579.cos.ap-guangzhou.myqcloud.com/17c71d650865473c94e8470d44daa920.png'}, {bankName:'阿克苏机场',image:'https://y2t-nfp-dev-1258746579.cos.ap-guangzhou.myqcloud.com/17c71d650865473c94e8470d44daa920.png'}, {bankName:'阿克苏机场',image:'https://y2t-nfp-dev-1258746579.cos.ap-guangzhou.myqcloud.com/17c71d650865473c94e8470d44daa920.png'}, {bankName:'阿克苏机场',image:'https://y2t-nfp-dev-1258746579.cos.ap-guangzhou.myqcloud.com/17c71d650865473c94e8470d44daa920.png'}, {bankName:'阿克苏机场',image:'https://y2t-nfp-dev-1258746579.cos.ap-guangzhou.myqcloud.com/17c71d650865473c94e8470d44daa920.png'}, {bankName:'阿克苏机场',image:'https://y2t-nfp-dev-1258746579.cos.ap-guangzhou.myqcloud.com/17c71d650865473c94e8470d44daa920.png'}]
				// }
			],
			isEmpty: false
		};
	},
	methods: {
		bindClick(e) {
			console.log('===========>', e);
			console.log('===========>', e.item.name.bankCode);
			console.log('===========>', e.item.name.bankName);
			console.log('===========>', e.item.name.id);
			var pages = getCurrentPages();
			var prevPage = pages[pages.length-2];
			prevPage.$vm.bankName = e.item.name.bankName
			prevPage.$vm.bankCode = e.item.name.bankCode
			prevPage.$vm.bankme = e.item.name.bankName
			uni.navigateBack({
				delta:1
			})
		},
		replaceInput: function(event) {
			this.bankName = event.target.value;
			this.querySuperBank();
		},
		querySuperBank(){
			this.wxRequest({
				url: `${this.API}/mini/jzb/querySuperBank`,
				method: 'POST',
				data:{
					bankName: this.bankName
				},
				title: '查询中...',
				success: res => {
					this.options = res.data.data
					console.log("dddd===========",res);
					if (!res.data.data || res.data.data.length === 0) {
						this.isEmpty = true
					}
				}
			});
		}
	},
	onLoad:function(options){
			this.bankName = options.bankName;
			this.querySuperBank();
	}
};
</script>

<style>
.row-css {
	display: flex;
	flex-direction: row;
}

.column-css {
	display: flex;
	flex-direction: column;
}
</style>
